package book_management.operation.impl;


import book_management.book.BookList;
import book_management.operation.IOperation;

/**
 *
 * @author yuisama
 * @date 2022/05/08 17:54
 **/
public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行的是添加书籍操作~");
        System.out.println("请输入您要添加的书籍名称:");
        String booksName = scanner.nextLine();
        // 假设此时书架上已经有这本书了呢~~
        if (bookList.contains(booksName)) {
            System.err.println(booksName + "在当前书架上已经存在了，无需添加");
            return;
        }
        System.out.println("请输入您要添加的书籍作者:");
        String author = scanner.nextLine();
        System.out.println("请输入您要添加的书籍类别:");
        String type = scanner.nextLine();
        System.out.println("请输入您要添加的书籍价格:");
        double price = scanner.nextDouble();
        // 吃掉\n换行符
        scanner.nextLine();
        // 产生书籍对象，保存到书架上
        bookList.addNewBook(booksName,author,type,price);
        System.out.println("添加书籍成功~");
    }
}